n = int(input())
nums = list(map(int, input().split()))


def way1():
    """
    暴力
    :return:
    """
    ans = 0
    for i in range(n):
        for j in range(i + 1, n):
            ans += nums[i] ^ nums[j]
    return ans


def way2():
    """
    考虑贡献
    :return:
    """
    ans = 0
    cnt = [0 for _ in range(32)]
    for num in nums:
        for bit in range(32):
            cnt[bit] += (num >> bit) & 1
    for bit in range(32):
        ans += (1 << bit) * cnt[bit] * (n - cnt[bit])
    return ans


if __name__ == '__main__':
    r1 = way1()
    r2 = way2()
    print(r1, r2)
